package edu.drexel.jrexel2d.gamestate;

import java.util.*;

import edu.drexel.jrexel2d.physics.*;

public class PhysicsState {
	
	private Vector<PhysicsObject2D> all2DPhysicsObjects = new Vector<PhysicsObject2D>();
	private ArrayList<Integer> activeObjects = new ArrayList<Integer>();
	private Vector<World2D> all2DWorlds = new Vector<World2D>();
	
	public PhysicsState(){
		//default constructor
	}
	
	public void add2DPhysicsObject(PhysicsObject2D inObject2D){
		all2DPhysicsObjects.add(inObject2D);
	}
	
	public void add2DWorld(World2D inWorld2D){
		all2DWorlds.add(inWorld2D);
	}
	
	public void remove2DPhysicsObject(int objectID){
		//TODO: remove from allObjects and activeObjects
	}
	
	public Vector<PhysicsObject2D> getAll2DPhysicsObjects(){
		return all2DPhysicsObjects;
	}
    
	public ArrayList<Integer> getActive2DObjects(){	
		return activeObjects;	
	}
	
	public void addActive2DObject(Integer inActiveObjectId){
		activeObjects.add(inActiveObjectId);
	}
	
	public PhysicsObject2D getPhysicsObjectById(int objId){
		
		PhysicsObject2D soughtAfterPhysicsObj = new PhysicsObject2D();
		
		for(PhysicsObject2D physObj : all2DPhysicsObjects){
			
			if(physObj.getObjectId() == objId){
				soughtAfterPhysicsObj = physObj;
			}
			
		}
		
		return soughtAfterPhysicsObj;
	}
	
	public World2D getWorldById(int inId){
		
		World2D retWorld = null;
		
		for(int i = 0; i < all2DWorlds.size(); ++i){
			
			if(all2DWorlds.get(i).getID() == inId){
				
				retWorld = all2DWorlds.get(i);
			}
			
		}
		
		return retWorld;
		
	}
	
}
